package com.cssy.authority.dao.impl;

import com.cssy.authority.dao.UserRoleDAO;
import com.cssy.authority.entity.UserRole;
import com.cssy.authority.entity.UserRoleExample;
import com.ibatis.sqlmap.client.SqlMapClient;
import java.sql.SQLException;
import java.util.List;

public class UserRoleDAOImpl implements UserRoleDAO {
    private SqlMapClient sqlMapClient;

    public UserRoleDAOImpl(SqlMapClient sqlMapClient) {
        super();
        this.sqlMapClient = sqlMapClient;
    }

    public void insert(UserRole record) throws SQLException {
        sqlMapClient.insert("sc_user_role.abatorgenerated_insert", record);
    }

    public int updateByPrimaryKey(UserRole record) throws SQLException {
        int rows = sqlMapClient.update("sc_user_role.abatorgenerated_updateByPrimaryKey", record);
        return rows;
    }

    public int updateByPrimaryKeySelective(UserRole record) throws SQLException {
        int rows = sqlMapClient.update("sc_user_role.abatorgenerated_updateByPrimaryKeySelective", record);
        return rows;
    }

    public List selectByExample(UserRoleExample example) throws SQLException {
        List list = sqlMapClient.queryForList("sc_user_role.abatorgenerated_selectByExample", example);
        return list;
    }

    public UserRole selectByPrimaryKey(Long id) throws SQLException {
        UserRole key = new UserRole();
        key.setId(id);
        UserRole record = (UserRole) sqlMapClient.queryForObject("sc_user_role.abatorgenerated_selectByPrimaryKey", key);
        return record;
    }

    public int deleteByExample(UserRoleExample example) throws SQLException {
        int rows = sqlMapClient.delete("sc_user_role.abatorgenerated_deleteByExample", example);
        return rows;
    }

    public int deleteByPrimaryKey(Long id) throws SQLException {
        UserRole key = new UserRole();
        key.setId(id);
        int rows = sqlMapClient.delete("sc_user_role.abatorgenerated_deleteByPrimaryKey", key);
        return rows;
    }

    public int countByExample(UserRoleExample example) throws SQLException {
        Integer count = (Integer)  sqlMapClient.queryForObject("sc_user_role.abatorgenerated_countByExample", example);
        return count.intValue();
    }

    public int updateByExampleSelective(UserRole record, UserRoleExample example) throws SQLException {
        UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
        int rows = sqlMapClient.update("sc_user_role.abatorgenerated_updateByExampleSelective", parms);
        return rows;
    }

    public int updateByExample(UserRole record, UserRoleExample example) throws SQLException {
        UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
        int rows = sqlMapClient.update("sc_user_role.abatorgenerated_updateByExample", parms);
        return rows;
    }

    private static class UpdateByExampleParms extends UserRoleExample {
        private Object record;

        public UpdateByExampleParms(Object record, UserRoleExample example) {
            super(example);
            this.record = record;
        }

        public Object getRecord() {
            return record;
        }
    }
}